<template>

	<view>
		<view class=''>

			<form>
				<view class="flex cu-form-group margin-top justify-between ">
					<view class="title">姓名：</view>
					<text>{{answerVO.myName}}</text>
				</view>
				<view class="flex cu-form-group margin-top justify-between ">
					<view class="title">破壳日：</view>
					<text>{{answerVO.myBirthdaty}}</text>
				</view>
				<view class="cu-form-group">
					<view class="title">梦想</view>
					<text>{{answerVO.myDream}}</text>
				</view>
				<view class="cu-form-group">
					<view class="title">电话</view>
					<text>{{answerVO.myPhone}}</text>
				</view>
				<view class="cu-form-group">
					<view class="title">对我的第一印象</view>
				</view>

				<view class='padding-sm flex flex-wrap'>
					<view class="padding-xs" v-for="(item) in impressionOptions" :key="item.name">
						<view v-if="!item.choosed" class='cu-tag line-green'>{{item.name}}</view>
						<view v-if="item.choosed" class='cu-tag bg-green'>{{item.name}}</view>
					</view>
				</view>

				<view class="cu-form-group flex-direction  align-start">
					<view class="title">最美好的回忆</view>
					<text>{{answerVO.bestMemory}}</text>
				</view>
				<view class="cu-form-group  flex-direction  align-start">
					<view class="title">最疯狂的经历</view>
					<text>{{answerVO.bestExperience}}</text>
				</view>
				<view class="cu-form-group  flex-direction   align-start">
					<view class="title">最猥琐的一面</view>
					<text>{{answerVO.bestBad}}</text>
				</view>
				<view class="cu-form-group  flex-direction   align-start">
					<view class="title">你想对我说的话</view>
					<text>{{answerVO.talk2me}}</text>
				</view>
				<view class="cu-bar bg-white margin-top">
					<view class="action">
						照片
					</view>
				</view>
				<view class="" v-for="(item,index) in imgList" :key="index" :data-url="imgList[index]">
					<image style="width: 100%;" :src="imgList[index]" mode="aspectFit"></image>
				</view>

			</form>


		</view>

	</view>

</template>

<script>
	import helper from '../../../common/helper.js';
	export default {
		data() {
			return {
				impressionDatas: [
					"文艺", "范二", "帅哥", "拉风", "软妹子",
					"女汉子", "手机控", "起床困难户", "购物狂",
					"技术宅", "待解救", "小清新", "月光族", "知识分子",
					"靠谱", "游戏控"
				],
				impressionOptions: [
					// {
					// 	name: "文艺",
					// 	choosed: false
					// }
				],
				impressionOptionsChooses: [],
				imgList: [],
				answerInfo: {},
				answerVO: {}

			};
		},

		onShow: function() {
			console.log('index onShow');
			let that = this;
			//that.getAnswerById(7);
		},
		onLoad: function(option) {
			console.log(option.answerId)

			//区分是从哪来的
			let answerId = option.answerId;
			if (answerId != '' && answerId != null && answerId != undefined) {
				this.getAnswerById(answerId);
			}


		},
		methods: {
			changeOptions() {
				let that = this;
				that.impressionOptions = that.impressionDatas.map((item, index, arr) => {
					let json = {}
					json.name = item;

					let i = that.impressionOptionsChooses.indexOf(item)
					if (i != -1) {
						json.choosed = true;
					} else {
						json.choosed = false;
					}
					return json;
				});
			},

			/**
			 * 提交
			 */
			getAnswerById(answerId) {

				let that = this;


				let playod = {
					answerId: answerId
				};

				uni.showLoading({
					title: "加载中"
				});
				uni.request({
					url: helper.api + '/appTxlBookAndAnswer/open/getAnswerById',
					method: 'get',
					data: playod,
					header: {
						'Content-Type': 'application/json' //自定义请求头信息
					},

					success: (res) => {
						console.log(res.data);
						uni.hideLoading();
						if (res.data.code === 0) {
							// todo 刷新数据

							that.answerInfo = res.data.data;
							that.answerVO = res.data.data.answerVO;
							that.impressionDatas = res.data.data.answerVO.impressionDatas;
							that.impressionOptionsChooses = res.data.data.answerVO.impressionOptionsChooses;
							that.imgList = res.data.data.answerVO.imageList
							debugger
							that.changeOptions();
						} else {
							uni.showModal({
								title: '请求失败！',
								content: '错误原因:' + res.data.msg,
								showCancel: false
							});
							return;
						}
					},
					fail: (err) => {
						uni.hideLoading();
						uni.showModal({
							title: '请求失败！',
							content: '错误原因:' + err,
							showCancel: false
						});
					}
				});

			}

		}
	}
</script>

<style lang="scss">

</style>
